home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / admin / linuxcon.000 / linuxcon / linuxconf-1.6 / netconf / routes1.c < prev    next >
C/C++ Source or Header  |  1996-07-19  |  1KB  |  48 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include "netconf.h"
  5. #include "../paths.h"
  6. #include "../xconf/xconf.h"
  7. #include "netconf.m"
  8.  
  9. extern NETCONF_HELP_FILE help_routes;
  10. /*
  11.     Edit a route configuration for a host or network (destination).
  12.  
  13.     Return 0 if edit is ok
  14.     return 1 if the user wish to delete this route
  15.     return -1 if the user escape from edit.
  16. */
  17. PUBLIC int ROUTE::edit(int edit_host_route)
  18. {
  19.     int ret = -1;
  20.     DIALOG dia;
  21.     dia.newf_str (MSG_U(F_GATEWAY,"Gateway"),ip_gateway);
  22.     dia.newf_str (MSG_U(F_DEST,"Destination"),ip_dst);
  23.     if (!edit_host_route) dia.newf_str (MSG_R(F_NETMASK),netmask);
  24.     int nof = 0;
  25.     while (1){
  26.         MENU_STATUS code = dia.edit(MSG_U(T_ROUTESPEC,"route specification")
  27.             ,MSG_U(I_ROUTESPEC,"Enter either IP numbers or names\n")
  28.             ,help_routes
  29.             ,nof,MENUBUT_CANCEL|MENUBUT_ACCEPT|MENUBUT_DEL);
  30.         if (code == MENU_CANCEL || code == MENU_ESCAPE){
  31.             break;
  32.         }else if (code == MENU_DEL){
  33.             ret = 1;
  34.             break;
  35.         }else if (code == MENU_ACCEPT){
  36.             if (ip_gateway.is_empty() || ip_dst.is_empty()){
  37.                 xconf_error (MSG_U(E_IVLROUTE,"Invalid route specification"));
  38.             }else{
  39.                 ret = 0;
  40.                 break;
  41.             }
  42.         }
  43.     }
  44.     if (ret != 0) dia.restore();
  45.     return ret;
  46. }
  47.  
  48.